package net.simflow.swf.analyzer.graph.opt;

import net.simflow.swf.analyzer.network.data.Node;

import org.apache.commons.collections15.Transformer;

public class NodeToLabelTransformer implements Transformer<Node, String> {

	private static final int STYLE_BLANK = 0;
	private static final int STYLE_SHORT_NAME = 1;
	private static final int STYLE_NAME = 2;

	private int style;

	public static NodeToLabelTransformer makeInstanceBlank() {
		return new NodeToLabelTransformer(STYLE_BLANK);
	}

	public static NodeToLabelTransformer makeInstanceShortName() {
		return new NodeToLabelTransformer(STYLE_SHORT_NAME);
	}

	public static NodeToLabelTransformer makeInstanceName() {
		return new NodeToLabelTransformer(STYLE_NAME);
	}

	private NodeToLabelTransformer(int style) {
		this.style = style;
	}

	@Override
	public String transform(Node node) {
		switch (style) {
		case STYLE_BLANK:
			return "";
		case STYLE_SHORT_NAME:
			return node.getShortInfo();
		case STYLE_NAME:
			return node.getFullInfo();
		}
		return "";
	}
}
